package myky.com.doctorapp.model


import com.xiangyao.train.utils.RxScedulerHelper
import io.reactivex.Observable
import myky.com.doctorapp.api.ApiManager
import myky.com.doctorapp.base.BaseEntity
import myky.com.doctorapp.contract.RemoteSubmitActivityContract
import myky.com.doctorapp.entity.RecordEntity
import myky.com.doctorapp.entity.RemoteAutoFillEntity
import myky.com.doctorapp.entity.RemoteRepeatEntity
import myky.com.doctorapp.entity.RemoteSubmitEntity
import myky.com.doctorapp.utils.Constants
import myky.com.doctorapp.utils.RequestBodyBuilder


/**
 * Description:
 *
 * @author wuyangwuyang
 * Created by 2019/1/11 on 10:27
 */
class RemoteSubmitActivityModel : RemoteSubmitActivityContract.Model {


    override fun getAutoFillDate(doctorId:Int): Observable<BaseEntity<RemoteAutoFillEntity.DataBean>> {
        val requestBodyBuilder = RequestBodyBuilder.Builder()
        requestBodyBuilder.params("version", Constants.CURRENTVERSION)
        requestBodyBuilder.params("doctorId", doctorId.toString())
        val requestBody = requestBodyBuilder.build()
        return ApiManager.getApistore().autoFillData(requestBody).compose(RxScedulerHelper.io_main())
    }
    override fun healthperfect(): Observable<BaseEntity<RecordEntity.PayLoadBean>> {
        return ApiManager.getApistore().isperfect().compose(RxScedulerHelper.io_main())
    }
    override fun isRepeat(doctorId: Int): Observable<BaseEntity<RemoteRepeatEntity.PayLoadBean>> {

        return ApiManager.getApistore().isRepeat(doctorId).compose(RxScedulerHelper.io_main())
    }


    override fun createRemote(remoteSubmit: RemoteSubmitEntity): Observable<BaseEntity<RemoteRepeatEntity.PayLoadBean>> {
        val requestBodyBuilder = RequestBodyBuilder.Builder()
        val requestBody=requestBodyBuilder.build(remoteSubmit)

        return ApiManager.getApistore().createRemote(requestBody).compose(RxScedulerHelper.io_main())
    }

}
